<?php
	if (!empty($banner['Banner'])) {
		switch ($banner['Banner']['kind']) {
			case 'I':
				$path = Configure::read('Lilads.uploadFolder');
				if (substr($path, 0, strlen(WWW_ROOT)) == WWW_ROOT) {
					// banner is in WWW_ROOT, display it directly
					$ad_url = Router::url('/', true).substr($path, strlen(WWW_ROOT)).'/'.$banner['Banner']['filename'];
				} else {
					$ad_url = $html->url(array('plugin'=>'lilads', 'controller'=>'banners', 'action'=>'display', $banner['Banner']['id']), true);
				}
				echo $html->link($html->image($ad_url,
					array(
						'width' => !empty($banner['Location']['width'])?$banner['Location']['width']:null,
						'height' => !empty($banner['Location']['height'])?$banner['Location']['height']:null,
					)),
					array('plugin'=>'lilads', 'controller'=>'banners', 'action'=>'click', $banner['Banner']['id']), 
					null, null, false);
				break;
			case 'F':
				if (substr($path, 0, strlen(WWW_ROOT)) == WWW_ROOT) {
					// banner is in WWW_ROOT, display it directly
					$ad_url = Router::url('/', true).substr($path, strlen(WWW_ROOT)).'/'.$banner['Banner']['filename'];
				} else {
					$ad_url = $html->url(array('plugin'=>'lilads', 'controller'=>'banners', 'action'=>'display', $banner['Banner']['id']), true);
				}
				echo '<object type="application/x-shockwave-flash" data="'.$ad_url.'"'.(!empty($banner['Location']['width'])?' width="'.$banner['Location']['width'].'"':'').(!empty($banner['Location']['height'])?' height="'.$banner['Location']['height'].'"':'').'>';
					echo '<param name="movie" value="'.$ad_url.'" />';
					echo '<param name="quality" value="high"/>';
				echo '</object>';
				break;
			case 'P':
				echo h($banner['Banner']['body']);
				break;
			case 'H':
				echo $banner['Banner']['body'];
				break;
		}
	}

?>